package com.bdq.user.infrastructure.persistence.mysql.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdq.user.infrastructure.persistence.mysql.pojo.UserFollow;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author malei
* @description 针对表【user_follow(用户关注关系表)】的数据库操作Mapper
* @createDate 2024-06-08 15:22:47
* @Entity generator.domain.UserFollow
*/
public interface UserFollowMapper extends BaseMapper<UserFollow> {

    @Select("SELECT * FROM user_follow WHERE follower_user_id = #{followerId} ORDER BY create_time DESC")
    IPage<UserFollow> pageFollower(Page<UserFollow> page, @Param("followerId") Long followerId);

    @Select("SELECT * FROM user_follow WHERE followed_user_id = #{followeeId} ORDER BY create_time DESC")
    IPage<UserFollow> pageFollowed(Page<UserFollow> page, @Param("followeeId") Long followeeId);

    @Select("SELECT * FROM user_follow WHERE follower_user_id = #{userId} AND followed_user_id IN " +
            "(SELECT follower_id FROM user_follow WHERE followed_user_id = #{userId}) ORDER BY create_time DESC")
    IPage<UserFollow> pageEachFollower(Page<UserFollow> page, @Param("userId") Long userId);
}




